package com.flx.jvm;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author Fenglixiong
 * @Create 2021/12/3 22:00
 * @Description
 **/
public class GCThread {

    public static Map<Integer,String> cacheMap = new HashMap<>();
    public static List<Student> studentList = new ArrayList<>();

    public static void main(String[] args) {

        new Thread(()->{
            try {
                int i = 1;
                while (i<10000000) {
                    cacheMap.put(i,"cache-"+i);
                    Thread.sleep(2000);
                    i++;
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        },"T1").start();

        new Thread(()->{
            try {
                int i = 1;
                while (i<1000000) {
                    studentList.add(new Student(i, "Student-" + (i)));
                    Thread.sleep(1000);
                    i++;
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        },"T2").start();

    }

    public static class Student{
        private Integer id;
        private String name;

        public Student() {
        }

        public Student(Integer id, String name) {
            this.id = id;
            this.name = name;
        }

        public Integer getId() {
            return id;
        }

        public void setId(Integer id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

}
